Javascript Regular Expressions: Count Leading Spaces [closed]

Posted by Jimmy on Stack Overflow See other posts from Stack Overflow or by Jimmy
Published on 2010-04-25T05:18:08Z Indexed on 2010/04/25 7:03 UTC
Read the original article Hit count: 270

Filed under:
|

Possible Duplicate:
Count number of matches of a regex in Javascript

How can I count the number of Leading spaces in a string. In this case it would be 4:

var s = "    Hello World";
//       ^^^^ <-- 4 leading spaces

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about regex